package com.example.studyroom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.studyroom.Entity.StudyRoomAdmin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudyRoomAdminMapper extends BaseMapper<StudyRoomAdmin> {
    //自习室管理员登录
    @Select("select * from StudyRoomAdmin where Rname = #{rname} and Rpass = #{rpass}")
    StudyRoomAdmin findByStudyRoomAdminLogin(String rname,String rpass);

    //显示所有自习室管理员
    @Select("SELECT * FROM StudyRoomAdmin")
    List<StudyRoomAdmin> getAllStudyRoomAdmins();

    //添加自习室管理员
    @Insert("INSERT INTO StudyRoomAdmin (Rname, Rpass, Room) VALUES (#{rname}, #{rpass}, #{room} )")
    void addStudyRoomAdmin(StudyRoomAdmin StudyRoomAdmin);

    //删除自习室管理员
    @Delete("DELETE FROM StudyRoomAdmin WHERE Rid = #{rid}")
    void deleteStudyRoomAdmin(Integer rid);

    //修改信息
    @Update("UPDATE StudyRoomAdmin SET Rpass = #{Rpass}, Room = #{Room} WHERE Rid = #{Rid}")
    void modifyStudyRoomAdmin(StudyRoomAdmin studyRoomAdmin);
}
